<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <div>
      <span>用户名：</span>
      <span>
        <input type="text" v-model.lazy='val'>
      </span>
      <span>{{msg}}</span>
    </div>
  </div>
  <script src="../vue.js"></script>
  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        val: '',
        msg: ''
      },
      methods: {
        handle(newVal) {
          setTimeout(() => {
            if (newVal === 'admin') {
              this.msg = '账号已存在，请重新验证....'
            } else {
              this.msg = '用户可以使用....'
            }
          }, 2000)
        }
      },
      watch: {
        val: function (newVal) {
          this.msg = '验证中....'
          this.handle(newVal)
        }
      }
    })
  </script>
</body>

</html>